#include<iostream>
#include<cmath>
using namespace std;
typedef pair<int, int> PII;
const int N = 200;
const double INF = 1e20;
#define x first
#define y second
int n;
PII q[N];
char g[N][N];
double dis[N][N], ma[N];
double get_dis(PII a, PII b)
{
	double dx = a.x - b.x, dy = a.y - b.y;
	return sqrt(dx * dx + dy * dy);
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> q[i].x >> q[i].y;
	}
	for (int i = 0; i < n; i++)cin >> g[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (g[i][j] == '1') {
				if (i != j)dis[i][j] = get_dis(q[i], q[j]);
			}
			else {
				if (i != j)dis[i][j] = INF;
			}
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	double ans1 = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dis[i][j] < INF) {
				ma[i] = max(ma[i], dis[i][j]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		ans1 = max(ans1, ma[i]);
	}
	double ans2 = INF;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dis[i][j] >= INF) {
				ans2 = min(ans2, ma[i] + get_dis(q[i], q[j]) + ma[j]);
			}
		}
	}
	printf("%lf\n", max(ans1, ans2));
	//cout << max(ans1, ans2) << endl;
	return 0;
}